package com.tusuo.stds.ui.question;

import android.app.Activity;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.github.lzyzsd.jsbridge.BridgeWebView;
import com.tusuo.stds.Constants;
import com.tusuo.stds.rest.LevelDetail;
import com.tusuo.stds.rest.Question;
import com.tusuo.stds.util.webview.WebViewManager;

import java.util.List;

/**
 * Created by developer on 17-6-12.
 */

public class QuestionAdapterForLevelRecord extends PagerAdapter {

    private LevelDetail mDetail;
    private List<View> mListView;
    private List<WebViewManager> mWebViewManagerList;
    private String mKey;
    private Activity mActivity;

   public QuestionAdapterForLevelRecord(List<View> listView, LevelDetail detail, List<WebViewManager> webViewManagerList, String key, Activity activity) {
        mDetail = detail;
        mListView = listView;
         mWebViewManagerList = webViewManagerList;
        mKey = key;
        mActivity = activity;
    }


    @Override
    public int getItemPosition(Object object) {

        return POSITION_NONE;
    }


    @Override
    public int getCount() {
        return mDetail.QuestionCount;   // 首添加一个空白页
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {  // 首多了1个空白页

        View view = mListView.get(position);

        if (view.getParent() == null) {
            Question question = mDetail.QuestionList.get(position);

            WebViewManager webViewManager = mWebViewManagerList.get(position);
            webViewManager.init();
            webViewManager.loadUrl(Constants.QUESTION_PAGE_TEMPLATE + "?type=review");

            webViewManager.initQuestion(question);

            container.addView(view);
        }

        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }




}
